import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
import { CommonEntity } from '@/common/entities/base.entity';
import { UPLOAD_STATUS, UPLOAD_STATUS_TYPE } from '@/common/enums'; // 引入新的 UPLOAD_STATUS 枚举

@Entity({
  name: 'sys_files_chunks',
  comment: '文件分片信息表',
})
export class FileChunks extends CommonEntity {
  @PrimaryGeneratedColumn({
    type: 'int',
    comment: '主键',
  })
  id: number;

  @Column({
    unique: true,
    comment: '文件唯一标识符',
    name: 'file_id',
  })
  fileId: string;

  @Column({
    comment: '分片索引，从0开始',
    name: 'chunk_index',
  })
  chunkIndex: number;

  @Column('bigint', {
    comment: '当前分片大小',
    name: 'chunk_size',
  })
  chunkSize: number;

  @Column({
    comment: '存储分片的路径（可以是本地路径或云存储路径）',
    name: 'chunk_path',
  })
  chunkPath: string;

  @Column({
    type: 'enum',
    enum: UPLOAD_STATUS, // 使用新的 UPLOAD_STATUS 枚举
    default: UPLOAD_STATUS.PENDING,
    comment: '分片状态',
    name: 'status',
  })
  status: UPLOAD_STATUS_TYPE;

}
